package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Objects;

@Entity
@Table(name = "demand_", schema = "crm")
public class Demand {
    private int demandId;
    private String demandTheme;
    private String demandOffer;
    private Date demandDate;
    private Integer demandSign;
    private String demandContent;
    private Opportunity opportunityByOppId;
    private Customer customerByCustomerId;

    @Id
    @Column(name = "demand_id", nullable = false)
    public int getDemandId() {
        return demandId;
    }

    public void setDemandId(int demandId) {
        this.demandId = demandId;
    }


    @Basic
    @Column(name = "demand_theme", nullable = true, length = 255)
    public String getDemandTheme() {
        return demandTheme;
    }

    public void setDemandTheme(String demandTheme) {
        this.demandTheme = demandTheme;
    }

    @Basic
    @Column(name = "demand_offer", nullable = true, length = 255)
    public String getDemandOffer() {
        return demandOffer;
    }

    public void setDemandOffer(String demandOffer) {
        this.demandOffer = demandOffer;
    }

    @Basic
    @Column(name = "demand_date", nullable = true)
    public Date getDemandDate() {
        return demandDate;
    }

    public void setDemandDate(Date demandDate) {
        this.demandDate = demandDate;
    }

    @Basic
    @Column(name = "demand_sign", nullable = true)
    public Integer getDemandSign() {
        return demandSign;
    }

    public void setDemandSign(Integer demandSign) {
        this.demandSign = demandSign;
    }

    @Basic
    @Column(name = "demand_content", nullable = true, length = 255)
    public String getDemandContent() {
        return demandContent;
    }

    public void setDemandContent(String demandContent) {
        this.demandContent = demandContent;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Demand demand = (Demand) o;
        return demandId == demand.demandId &&
                Objects.equals(demandTheme, demand.demandTheme) &&
                Objects.equals(demandOffer, demand.demandOffer) &&
                Objects.equals(demandDate, demand.demandDate) &&
                Objects.equals(demandSign, demand.demandSign) &&
                Objects.equals(demandContent, demand.demandContent);
    }

    @Override
    public int hashCode() {
        return Objects.hash(demandId, demandTheme, demandOffer, demandDate, demandSign, demandContent);
    }

    @ManyToOne
    @JoinColumn(name = "opp_id", referencedColumnName = "opp_id")
    public Opportunity getOpportunityByOppId() {
        return opportunityByOppId;
    }

    public void setOpportunityByOppId(Opportunity opportunityByOppId) {
        this.opportunityByOppId = opportunityByOppId;
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }
}
